/**
 * Created by zhangjinrui on 17/6/27.
 */

public class Solution456 {

    public static void main(String args[]) {
        Solution456 s = new Solution456();
        System.out.println(s.find132pattern(new int[]{1, 1, 1}));
    }

    public boolean find132pattern(int[] nums) {
        int n = nums.length;
        if (n < 3) {
            return false;
        }

        int l = 0;
        while (l < n - 2) {
            while (l + 1 < n && nums[l + 1] <= nums[l]) {
                l++;
            }
            if (l >= n - 2) {
                return false;
            }

            int mid = l + 1;
            while (mid + 1 < n && nums[mid + 1] >= nums[mid]) {
                mid++;
            }
            if (mid >= n - 1) {
                return false;
            }
            if (nums[mid + 1] > nums[l]) {
                return true;
            } else {
                l = mid + 1;
            }
        }
        return false;
    }

}
